<?php 

class Item extends PXFModel
{
	public $relations = array(
		'created_by'=> array('type' => 'm_o', 'fkey' => 'created_by', 'table' => 'user'),
		'edited_by' => array('type' => 'm_o', 'fkey' => 'edited_by', 'table' => 'user'),
		'category' => array('type' => 'm_m'),
		'image'    => array('type' => 'm_o', 'fkey' => 'image_id', 'table' => 'item_image'),
		'images'   => array('type' => 'o_m', 'fkey' => 'item_id',  'table' => 'item_image'),
	);
	public $languages = array(
		'title','intro','content'
	);
}

class User extends PXFModel
{
	public $relations = array(
		'profile' => array('type' => 'm_o', 'fkey' => 'profile_id'),
		'item'    => array('type' => 'o_m', 'fkey' => 'user_id'),
		'corder'  => array('type' => 'o_m', 'fkey' => 'user_id'),
		'contact' => array('type' => 'o_m', 'fkey' => 'user_id'),
	);

	public function identify($mail,$passwd)
	{
		$cond = new PXFCondition('mail',$mail);
		$cond->add(PXFCondition::opAND('pswd',md5($passwd)));
		$user = $this->findBy(array('condition' => $cond),true);
		return $user;
	}
}

class Category extends PXFModel
{
	public $relations = array(
		'item' => array('type' => 'm_m'),
	);
	public $languages = array(
		'title'
	);
}

class Item_Image extends PXFModel
{
	public $relations = array(
		'item' => array('type' => 'm_m'),
	);
}

class Profile extends PXFModel
{
	public $relations = array(
		'paccess' => array('type' => 'o_m'),
	);
}

class Paccess extends PXFModel
{
	public $relations = array(
		'profile' => array('type' => 'm_o'),
	);
}

class Session extends PXFModel
{
	public $relations = array(
		'profile' => array('type' => 'm_o'),
	);
}

class Contact extends PXFModel
{
	public $relations = array(
		'user'          => array('type' => 'm_o', 'fkey' => 'user_id'),
	);
}

class Comment extends PXFModel
{
	public $relations = array(
		'user' => array('type' => 'm_o', 'fkey' => 'user_id'),
		'item' => array('type' => 'm_o', 'fkey' => 'item_id'),
	);
}

?>
